package com.bz.content.service.impl;

import com.bz.content.feign.CommonContentFeignClient;
import com.bz.content.service.ContentService;
import com.bz.pojo.TbContent;
import com.bz.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ContentServiceImpl implements ContentService {

    @Autowired
    private CommonContentFeignClient commonContentFeignClient;

    /**
     * 根据分类查询内容
     * @param page
     * @param rows
     * @param categoryId
     * @return
     */
    @Override
    public Result selectTbContentAllByCategoryId(Integer page, Integer rows, Long categoryId) {
        return Result.ok(commonContentFeignClient.selectTbContentAllByCategoryId(page,rows,categoryId));
    }

    /**
     * 根据分类添加内容
     * @param tbContent
     * @return
     */
    @Override
    public Result insertTbContent(TbContent tbContent) {
        Integer result = commonContentFeignClient.insertTbContent(tbContent);
        if (result != null){
            return Result.ok();
        }
        return Result.error("操作失败");
    }

    /**
     * 删除分类下的内容
     * @param id
     * @return
     */
    @Override
    public Result deleteContentByIds(Long id) {
        Integer result = commonContentFeignClient.deleteContentByIds(id);
        if (result != null){
            return Result.ok();
        }
        return Result.error("操作失败");
    }
}
